<!DOCTYPE html>
<html lang="en">
  <head>
    <title>BTree Struct Reference</title>
    <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="../css/highlight.css" />
    <meta charset="utf-8">
    <script src="../js/jquery.min.js" defer></script>
    <script src="../js/jazzy.js" defer></script>
    
  </head>
  <body>

    <a name="//apple_ref/swift/Struct/BTree" class="dashAnchor"></a>

    <a title="BTree Struct Reference"></a>

    <header class="header">
      <p class="header-col header-col--primary">
        <a class="header-link" href="../index.html">
          BTree Docs
        </a>
         (100% documented)
      </p>
    
        <p class="header-col header-col--secondary">
          <a class="header-link" href="https://github.com/lorentey/BTree">
            <img class="header-icon" src="../img/gh.png"/>
            View on GitHub
          </a>
        </p>
    
        <p class="header-col header-col--secondary">
          <a class="header-link" href="dash-feed://https%3A%2F%2Florentey%2Egithub%2Eio%2FBTree%2Freference%2Fdocsets%2FBTree%2Exml">
            <img class="header-icon" src="../img/dash.png"/>
            Install in Dash
          </a>
        </p>
    </header>

    <p class="breadcrumbs">
      <a class="breadcrumb" href="../index.html">BTree Reference</a>
      <img class="carat" src="../img/carat.png" />
      BTree Struct Reference
    </p>

    <div class="content-wrapper">
      <nav class="navigation">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Classes/BTreeCursor.html">BTreeCursor</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../Enums.html">Enums</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Enums/BTreeKeySelector.html">BTreeKeySelector</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Enums/BTreeMatchingStrategy.html">BTreeMatchingStrategy</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="../Structs.html">Structs</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/BTree.html">BTree</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/BTreeIndex.html">BTreeIndex</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/BTreeIterator.html">BTreeIterator</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/BTreeKeyIterator.html">BTreeKeyIterator</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/BTreeValueIterator.html">BTreeValueIterator</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/List.html">List</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/Map.html">Map</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/SortedBag.html">SortedBag</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="../Structs/SortedSet.html">SortedSet</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">

        <section class="section">
          <div class="section-content">
            <h1>BTree</h1>
              <div class="declaration">
                <div class="language">
                  <pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">BTree</span><span class="o">&lt;</span><span class="kt">Key</span><span class="p">:</span> <span class="kt">Comparable</span><span class="p">,</span> <span class="kt">Value</span><span class="o">&gt;</span></code></pre>

                </div>
              </div>
            <p>B-trees are search trees that provide an ordered key-value store with excellent performance characteristics.</p>

          </div>
        </section>

        <section class="section">
          <div class="section-content">
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Definition"></a>
                <a name="//apple_ref/swift/Section/Definition" class="dashAnchor"></a>
                <a href="#/Definition">
                  <h3 class="section-name">Definition</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTreecFT5orderSi_GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/init(order:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTreecFT5orderSi_GS0_xq__">init(order:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Initialize a new B-tree with no elements.</p>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    Parameter order: The maximum number of children for tree nodes.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">order</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="kt">Node</span><span class="o">.</span><span class="n">defaultOrder</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>order</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The maximum number of children for tree nodes.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L26-L28">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree5BTree5orderSi"></a>
                    <a name="//apple_ref/swift/Property/order" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree5BTree5orderSi">order</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>The order of this tree, i.e., the maximum number of children for tree nodes.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">order</span><span class="p">:</span> <span class="kt">Int</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L31">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree5BTree5depthSi"></a>
                    <a name="//apple_ref/swift/Property/depth" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree5BTree5depthSi">depth</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>The depth of this tree. Depth starts at 0 for a tree that has a single root node.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">depth</span><span class="p">:</span> <span class="kt">Int</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L33">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Sequence"></a>
                <a name="//apple_ref/swift/Section/Sequence" class="dashAnchor"></a>
                <a href="#/Sequence">
                  <h3 class="section-name">Sequence</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree5BTree7isEmptySb"></a>
                    <a name="//apple_ref/swift/Property/isEmpty" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree5BTree7isEmptySb">isEmpty</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns true iff this tree has no elements.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">isEmpty</span><span class="p">:</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L62">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree12makeIteratorFT_GVS_13BTreeIteratorxq__"></a>
                    <a name="//apple_ref/swift/Method/makeIterator()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree12makeIteratorFT_GVS_13BTreeIteratorxq__">makeIterator()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns an iterator over the elements of this B-tree. Elements are sorted by key.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">makeIterator</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Iterator</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L65-L67">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree12makeIteratorFT4fromGVS_10BTreeIndexxq___GVS_13BTreeIteratorxq__"></a>
                    <a name="//apple_ref/swift/Method/makeIterator(from:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree12makeIteratorFT4fromGVS_10BTreeIndexxq___GVS_13BTreeIteratorxq__">makeIterator(from:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns an iterator starting at a specific index.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">makeIterator</span><span class="p">(</span><span class="n">from</span> <span class="nv">index</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Iterator</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L70-L73">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree12makeIteratorFT10fromOffsetSi_GVS_13BTreeIteratorxq__"></a>
                    <a name="//apple_ref/swift/Method/makeIterator(fromOffset:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree12makeIteratorFT10fromOffsetSi_GVS_13BTreeIteratorxq__">makeIterator(fromOffset:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns an iterator starting at a specific offset.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">makeIterator</span><span class="p">(</span><span class="n">fromOffset</span> <span class="nv">offset</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Iterator</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L76-L78">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree12makeIteratorFT4fromx8choosingOS_16BTreeKeySelector_GVS_13BTreeIteratorxq__"></a>
                    <a name="//apple_ref/swift/Method/makeIterator(from:choosing:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree12makeIteratorFT4fromx8choosingOS_16BTreeKeySelector_GVS_13BTreeIteratorxq__">makeIterator(from:choosing:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns an iterator starting at the element with the specified key.
If the tree contains no such element, the generator is positioned on the first element with a larger key.
If there are multiple elements with the same key, <code>selector</code> indicates which matching element to find.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">makeIterator</span><span class="p">(</span><span class="n">from</span> <span class="nv">key</span><span class="p">:</span> <span class="kt">Key</span><span class="p">,</span> <span class="n">choosing</span> <span class="nv">selector</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeKeySelector.html">BTreeKeySelector</a></span> <span class="o">=</span> <span class="o">.</span><span class="n">any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Iterator</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L83-L85">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree7forEachFzFzTxq__T_T_"></a>
                    <a name="//apple_ref/swift/Method/forEach(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree7forEachFzFzTxq__T_T_">forEach(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Call <code>body</code> on each element in self in the same order as a for-in loop.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">forEach</span><span class="p">(</span><span class="n">_</span> <span class="nv">body</span><span class="p">:</span> <span class="p">(</span><span class="kt">Element</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="p">())</span> <span class="k">rethrows</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L88-L90">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree7forEachFzFzTxq__SbSb"></a>
                    <a name="//apple_ref/swift/Method/forEach(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree7forEachFzFzTxq__SbSb">forEach(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>A version of <code>forEach</code> that allows <code>body</code> to interrupt iteration by returning <code>false</code>.</p>

<div class="aside aside-returns">
    <p class="aside-title">Returns</p>
    <code>true</code> iff <code>body</code> returned true for all elements in the tree.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">forEach</span><span class="p">(</span><span class="n">_</span> <span class="nv">body</span><span class="p">:</span> <span class="p">(</span><span class="kt">Element</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">Bool</span><span class="p">)</span> <span class="k">rethrows</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p><code>true</code> iff <code>body</code> returned true for all elements in the tree.</p>

                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L96-L98">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/CollectionType"></a>
                <a name="//apple_ref/swift/Section/CollectionType" class="dashAnchor"></a>
                <a href="#/CollectionType">
                  <h3 class="section-name">CollectionType</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:iV5BTree5BTree9subscriptFGVS_10BTreeIndexxq__Txq__"></a>
                    <a name="//apple_ref/swift/Method/subscript(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:iV5BTree5BTree9subscriptFGVS_10BTreeIndexxq__Txq__">subscript(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the element at <code>index</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(1)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="nv">index</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Element</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L129">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:iV5BTree5BTree9subscriptFGVs5RangeGVS_10BTreeIndexxq___GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/subscript(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:iV5BTree5BTree9subscriptFGVs5RangeGVS_10BTreeIndexxq___GS0_xq__">subscript(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a tree consisting of elements in the specified range of indexes.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="nf">subscript</span><span class="p">(</span><span class="nv">range</span><span class="p">:</span> <span class="kt">Range</span><span class="o">&lt;</span><span class="kt">Index</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span><span class="o">&lt;</span><span class="kt">Key</span><span class="p">,</span> <span class="kt">Value</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L139">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree5BTree10startIndexGVS_10BTreeIndexxq__"></a>
                    <a name="//apple_ref/swift/Property/startIndex" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree5BTree10startIndexGVS_10BTreeIndexxq__">startIndex</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>The index of the first element of this tree. Elements are sorted by key.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">startIndex</span><span class="p">:</span> <span class="kt">Index</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L110-L112">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree5BTree8endIndexGVS_10BTreeIndexxq__"></a>
                    <a name="//apple_ref/swift/Property/endIndex" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree5BTree8endIndexGVS_10BTreeIndexxq__">endIndex</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>The index after the last element of this tree. (Equals <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree10startIndexGVS_10BTreeIndexxq__">startIndex</a></code> when the tree is empty.)</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(1)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">endIndex</span><span class="p">:</span> <span class="kt">Index</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L117-L119">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree5BTree5countSi"></a>
                    <a name="//apple_ref/swift/Property/count" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree5BTree5countSi">count</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>The number of elements in this tree.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">count</span><span class="p">:</span> <span class="kt">Int</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L122-L124">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree5indexFT5afterGVS_10BTreeIndexxq___GS1_xq__"></a>
                    <a name="//apple_ref/swift/Method/index(after:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree5indexFT5afterGVS_10BTreeIndexxq___GS1_xq__">index(after:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the successor of the given index.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> is a valid index of this tree and it is not equal to <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree8endIndexGVS_10BTreeIndexxq__">endIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    Amortized O(1).

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">index</span><span class="p">(</span><span class="n">after</span> <span class="nv">index</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Index</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L153-L158">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree9formIndexFT5afterRGVS_10BTreeIndexxq___T_"></a>
                    <a name="//apple_ref/swift/Method/formIndex(after:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree9formIndexFT5afterRGVS_10BTreeIndexxq___T_">formIndex(after:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Replaces the given index with its successor.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> is a valid index of this tree and it is not equal to <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree8endIndexGVS_10BTreeIndexxq__">endIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    Amortized O(1).

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">formIndex</span><span class="p">(</span><span class="n">after</span> <span class="nv">index</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Index</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L164-L167">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree5indexFT6beforeGVS_10BTreeIndexxq___GS1_xq__"></a>
                    <a name="//apple_ref/swift/Method/index(before:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree5indexFT6beforeGVS_10BTreeIndexxq___GS1_xq__">index(before:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the predecessor of the given index.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> is a valid index of this tree and it is not equal to <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree10startIndexGVS_10BTreeIndexxq__">startIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    Amortized O(1).

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">index</span><span class="p">(</span><span class="n">before</span> <span class="nv">index</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Index</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L173-L178">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree9formIndexFT6beforeRGVS_10BTreeIndexxq___T_"></a>
                    <a name="//apple_ref/swift/Method/formIndex(before:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree9formIndexFT6beforeRGVS_10BTreeIndexxq___T_">formIndex(before:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Replaces the given index with its predecessor.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> is a valid index of this tree and it is not equal to <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree10startIndexGVS_10BTreeIndexxq__">startIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    Amortized O(1).

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">formIndex</span><span class="p">(</span><span class="n">before</span> <span class="nv">index</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Index</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L184-L187">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree5indexFTGVS_10BTreeIndexxq__8offsetBySi_GS1_xq__"></a>
                    <a name="//apple_ref/swift/Method/index(_:offsetBy:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree5indexFTGVS_10BTreeIndexxq__8offsetBySi_GS1_xq__">index(_:offsetBy:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns an index that is the specified distance from the given index.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> must be a valid index of this tree.
         If <code>n</code> is positive, it must not exceed the distance from <code>index</code> to <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree8endIndexGVS_10BTreeIndexxq__">endIndex</a></code>. 
         If <code>n</code> is negative, it must not be less than the distance from <code>index</code> to <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree10startIndexGVS_10BTreeIndexxq__">startIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<em>count</em>)) where <em>count</em> is the number of elements in the tree.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">index</span><span class="p">(</span><span class="n">_</span> <span class="nv">i</span><span class="p">:</span> <span class="kt">Index</span><span class="p">,</span> <span class="n">offsetBy</span> <span class="nv">n</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Index</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L195-L200">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree9formIndexFTRGVS_10BTreeIndexxq__8offsetBySi_T_"></a>
                    <a name="//apple_ref/swift/Method/formIndex(_:offsetBy:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree9formIndexFTRGVS_10BTreeIndexxq__8offsetBySi_T_">formIndex(_:offsetBy:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Offsets the given index by the specified distance.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> must be a valid index of this tree.
         If <code>n</code> is positive, it must not exceed the distance from <code>index</code> to <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree8endIndexGVS_10BTreeIndexxq__">endIndex</a></code>.
         If <code>n</code> is negative, it must not be less than the distance from <code>index</code> to <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree10startIndexGVS_10BTreeIndexxq__">startIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<em>count</em>)) where <em>count</em> is the number of elements in the tree.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">formIndex</span><span class="p">(</span><span class="n">_</span> <span class="nv">i</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Index</span><span class="p">,</span> <span class="n">offsetBy</span> <span class="nv">n</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L208-L211">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree5indexFTGVS_10BTreeIndexxq__8offsetBySi9limitedByGS1_xq___GSqGS1_xq___"></a>
                    <a name="//apple_ref/swift/Method/index(_:offsetBy:limitedBy:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree5indexFTGVS_10BTreeIndexxq__8offsetBySi9limitedByGS1_xq___GSqGS1_xq___">index(_:offsetBy:limitedBy:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns an index that is the specified distance from the given index, unless that distance is beyond a given limiting index.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> and <code>limit</code> must be valid indices of this tree. The operation must not advance the index beyond <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree8endIndexGVS_10BTreeIndexxq__">endIndex</a></code> or before <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree10startIndexGVS_10BTreeIndexxq__">startIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<em>count</em>)) where <em>count</em> is the number of elements in the tree.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">index</span><span class="p">(</span><span class="n">_</span> <span class="nv">i</span><span class="p">:</span> <span class="kt">Index</span><span class="p">,</span> <span class="n">offsetBy</span> <span class="nv">n</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span> <span class="n">limitedBy</span> <span class="nv">limit</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Index</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L217-L227">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree9formIndexFTRGVS_10BTreeIndexxq__8offsetBySi9limitedByGS1_xq___Sb"></a>
                    <a name="//apple_ref/swift/Method/formIndex(_:offsetBy:limitedBy:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree9formIndexFTRGVS_10BTreeIndexxq__8offsetBySi9limitedByGS1_xq___Sb">formIndex(_:offsetBy:limitedBy:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Offsets the given index by the specified distance, or so that it equals the given limiting index.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>index</code> and <code>limit</code> must be valid indices of this tree. The operation must not advance the index beyond <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree8endIndexGVS_10BTreeIndexxq__">endIndex</a></code> or before <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree10startIndexGVS_10BTreeIndexxq__">startIndex</a></code>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<em>count</em>)) where <em>count</em> is the number of elements in the tree.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">formIndex</span><span class="p">(</span><span class="n">_</span> <span class="nv">i</span><span class="p">:</span> <span class="k">inout</span> <span class="kt">Index</span><span class="p">,</span> <span class="n">offsetBy</span> <span class="nv">n</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span> <span class="n">limitedBy</span> <span class="nv">limit</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L234-L238">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree8distanceFT4fromGVS_10BTreeIndexxq__2toGS1_xq___Si"></a>
                    <a name="//apple_ref/swift/Method/distance(from:to:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree8distanceFT4fromGVS_10BTreeIndexxq__2toGS1_xq___Si">distance(from:to:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the distance between two indices.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>start</code> and <code>end</code> must be valid indices in this tree.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(1)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">distance</span><span class="p">(</span><span class="n">from</span> <span class="nv">start</span><span class="p">:</span> <span class="kt">Index</span><span class="p">,</span> <span class="n">to</span> <span class="nv">end</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Int</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L245-L249">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Lookups"></a>
                <a name="//apple_ref/swift/Section/Lookups" class="dashAnchor"></a>
                <a href="#/Lookups">
                  <h3 class="section-name">Lookups</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree5BTree5firstGSqTxq___"></a>
                    <a name="//apple_ref/swift/Property/first" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree5BTree5firstGSqTxq___">first</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the first element in this tree, or <code>nil</code> if the tree is empty.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">first</span><span class="p">:</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L286-L288">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:vV5BTree5BTree4lastGSqTxq___"></a>
                    <a name="//apple_ref/swift/Property/last" class="dashAnchor"></a>
                    <a class="token" href="#/s:vV5BTree5BTree4lastGSqTxq___">last</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the last element in this tree, or <code>nil</code> if the tree is empty.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">last</span><span class="p">:</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L293-L295">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree7elementFT8atOffsetSi_Txq__"></a>
                    <a name="//apple_ref/swift/Method/element(atOffset:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree7elementFT8atOffsetSi_Txq__">element(atOffset:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the element at <code>offset</code>.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>offset &gt;= 0 &amp;&amp; offset &lt; count</code>

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">element</span><span class="p">(</span><span class="n">atOffset</span> <span class="nv">offset</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Element</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L301-L315">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree5valueFT2ofx8choosingOS_16BTreeKeySelector_GSqq__"></a>
                    <a name="//apple_ref/swift/Method/value(of:choosing:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree5valueFT2ofx8choosingOS_16BTreeKeySelector_GSqq__">value(of:choosing:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the value of an element of this tree with the specified key, or <code>nil</code> if there is no such element.
If there are multiple elements with the same key, <code>selector</code> indicates which matching element to find.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">value</span><span class="p">(</span><span class="n">of</span> <span class="nv">key</span><span class="p">:</span> <span class="kt">Key</span><span class="p">,</span> <span class="n">choosing</span> <span class="nv">selector</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeKeySelector.html">BTreeKeySelector</a></span> <span class="o">=</span> <span class="o">.</span><span class="n">any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Value</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L321-L351">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree5indexFT6forKeyx8choosingOS_16BTreeKeySelector_GSqGVS_10BTreeIndexxq___"></a>
                    <a name="//apple_ref/swift/Method/index(forKey:choosing:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree5indexFT6forKeyx8choosingOS_16BTreeKeySelector_GSqGVS_10BTreeIndexxq___">index(forKey:choosing:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns an index to an element in this tree with the specified key, or <code>nil</code> if there is no such element.
If there are multiple elements with the same key, <code>selector</code> indicates which matching element to find.</p>

<p>This method never returns <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree8endIndexGVS_10BTreeIndexxq__">endIndex</a></code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">index</span><span class="p">(</span><span class="n">forKey</span> <span class="nv">key</span><span class="p">:</span> <span class="kt">Key</span><span class="p">,</span> <span class="n">choosing</span> <span class="nv">selector</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeKeySelector.html">BTreeKeySelector</a></span> <span class="o">=</span> <span class="o">.</span><span class="n">any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Index</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L359-L363">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree5indexFT12forInsertingx2atOS_16BTreeKeySelector_GVS_10BTreeIndexxq__"></a>
                    <a name="//apple_ref/swift/Method/index(forInserting:at:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree5indexFT12forInsertingx2atOS_16BTreeKeySelector_GVS_10BTreeIndexxq__">index(forInserting:at:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns an index that points to the position where a new element with the specified key would
be inserted into this tree. This is useful for finding the nearest element above or below <code>key</code>.</p>

<p>The returned index may be <code><a href="../Structs/BTree.html#/s:vV5BTree5BTree8endIndexGVS_10BTreeIndexxq__">endIndex</a></code> if the tree is empty or <code>key</code> is greater than or equal to the key of the largest element.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">index</span><span class="p">(</span><span class="n">forInserting</span> <span class="nv">key</span><span class="p">:</span> <span class="kt">Key</span><span class="p">,</span> <span class="n">at</span> <span class="nv">selector</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeKeySelector.html">BTreeKeySelector</a></span> <span class="o">=</span> <span class="o">.</span><span class="n">any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Index</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L371-L374">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6offsetFT6forKeyx8choosingOS_16BTreeKeySelector_GSqSi_"></a>
                    <a name="//apple_ref/swift/Method/offset(forKey:choosing:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6offsetFT6forKeyx8choosingOS_16BTreeKeySelector_GSqSi_">offset(forKey:choosing:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the offset of the first element in this tree with the specified key, or <code>nil</code> if there is no such element.
If there are multiple elements with the same key, <code>selector</code> indicates which matching element to find.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">offset</span><span class="p">(</span><span class="n">forKey</span> <span class="nv">key</span><span class="p">:</span> <span class="kt">Key</span><span class="p">,</span> <span class="n">choosing</span> <span class="nv">selector</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeKeySelector.html">BTreeKeySelector</a></span> <span class="o">=</span> <span class="o">.</span><span class="n">any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Int</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L380-L402">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6offsetFT2ofGVS_10BTreeIndexxq___Si"></a>
                    <a name="//apple_ref/swift/Method/offset(of:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6offsetFT2ofGVS_10BTreeIndexxq___Si">offset(of:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the offset of the element at <code>index</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(1)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">offset</span><span class="p">(</span><span class="n">of</span> <span class="nv">index</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Int</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L407-L410">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree5indexFT8ofOffsetSi_GVS_10BTreeIndexxq__"></a>
                    <a name="//apple_ref/swift/Method/index(ofOffset:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree5indexFT8ofOffsetSi_GVS_10BTreeIndexxq__">index(ofOffset:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns the index of the element at <code>offset</code>.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>offset &gt;= 0 &amp;&amp; offset &lt;= count</code>

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">index</span><span class="p">(</span><span class="n">ofOffset</span> <span class="nv">offset</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Index</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L416-L418">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Editing"></a>
                <a name="//apple_ref/swift/Section/Editing" class="dashAnchor"></a>
                <a href="#/Editing">
                  <h3 class="section-name">Editing</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree8setValueFT8atOffsetSi2toq__q_"></a>
                    <a name="//apple_ref/swift/Method/setValue(atOffset:to:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree8setValueFT8atOffsetSi2toq__q_">setValue(atOffset:to:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Set the value at <code>offset</code>, and return the value originally stored there.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>offset &lt; count</code>

</div>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    When you need to perform multiple modifications on the same tree,
<code><a href="../Classes/BTreeCursor.html">BTreeCursor</a></code> provides an alternative interface that&rsquo;s often more efficient.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">setValue</span><span class="p">(</span><span class="n">atOffset</span> <span class="nv">offset</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span> <span class="n">to</span> <span class="nv">value</span><span class="p">:</span> <span class="kt">Value</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Value</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L472-L493">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Insertion"></a>
                <a name="//apple_ref/swift/Section/Insertion" class="dashAnchor"></a>
                <a href="#/Insertion">
                  <h3 class="section-name">Insertion</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6insertFTTxq__8atOffsetSi_T_"></a>
                    <a name="//apple_ref/swift/Method/insert(_:atOffset:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6insertFTTxq__8atOffsetSi_T_">insert(_:atOffset:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Insert the specified element into the tree at <code>offset</code>.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    The key of the supplied element does not violate the B-tree&rsquo;s ordering requirement.
(This is only verified in non-optimized builds.)

</div>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    When you need to perform multiple modifications on the same tree,
<code><a href="../Classes/BTreeCursor.html">BTreeCursor</a></code> provides an alternative interface that&rsquo;s often more efficient.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">insert</span><span class="p">(</span><span class="n">_</span> <span class="nv">element</span><span class="p">:</span> <span class="kt">Element</span><span class="p">,</span> <span class="n">atOffset</span> <span class="nv">offset</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L504-L545">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6insertFTTxq__2atOS_16BTreeKeySelector_T_"></a>
                    <a name="//apple_ref/swift/Method/insert(_:at:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6insertFTTxq__2atOS_16BTreeKeySelector_T_">insert(_:at:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Insert <code>element</code> into the tree as a new element.
If the tree already contains elements with the same key, <code>selector</code> specifies where to put the new element.</p>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    When you need to perform multiple modifications on the same tree,
<code><a href="../Classes/BTreeCursor.html">BTreeCursor</a></code> provides an alternative interface that&rsquo;s often more efficient.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">insert</span><span class="p">(</span><span class="n">_</span> <span class="nv">element</span><span class="p">:</span> <span class="kt">Element</span><span class="p">,</span> <span class="n">at</span> <span class="nv">selector</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeKeySelector.html">BTreeKeySelector</a></span> <span class="o">=</span> <span class="o">.</span><span class="n">any</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L553-L580">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree15insertOrReplaceFTTxq__2atOS_16BTreeKeySelector_GSqTxq___"></a>
                    <a name="//apple_ref/swift/Method/insertOrReplace(_:at:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree15insertOrReplaceFTTxq__2atOS_16BTreeKeySelector_GSqTxq___">insertOrReplace(_:at:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Insert <code>element</code> into the tree, replacing an element with the same key if there is one.
If the tree already contains multiple elements with the same key, <code>selector</code> specifies which one to replace.</p>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    When you need to perform multiple modifications on the same tree,
<code><a href="../Classes/BTreeCursor.html">BTreeCursor</a></code> provides an alternative interface that&rsquo;s often more efficient.

</div>

<div class="aside aside-returns">
    <p class="aside-title">Returns</p>
    The element previously stored in the tree at the specified key.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">insertOrReplace</span><span class="p">(</span><span class="n">_</span> <span class="nv">element</span><span class="p">:</span> <span class="kt">Element</span><span class="p">,</span> <span class="n">at</span> <span class="nv">selector</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeKeySelector.html">BTreeKeySelector</a></span> <span class="o">=</span> <span class="o">.</span><span class="n">any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>The element previously stored in the tree at the specified key.</p>

                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L590-L648">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree12insertOrFindFTTxq__2atOS_16BTreeKeySelector_GSqTxq___"></a>
                    <a name="//apple_ref/swift/Method/insertOrFind(_:at:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree12insertOrFindFTTxq__2atOS_16BTreeKeySelector_GSqTxq___">insertOrFind(_:at:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Find and return an element that has the same key as <code>element</code> if there is one, 
or insert <code>element</code> in the tree and return nil.</p>

<p>If the tree already contains multiple elements with the same key, <code>selector</code> specifies which one to return.</p>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    When you need to perform multiple modifications on the same tree,
<code><a href="../Classes/BTreeCursor.html">BTreeCursor</a></code> provides an alternative interface that&rsquo;s often more efficient.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">insertOrFind</span><span class="p">(</span><span class="n">_</span> <span class="nv">element</span><span class="p">:</span> <span class="kt">Element</span><span class="p">,</span> <span class="n">at</span> <span class="nv">selector</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeKeySelector.html">BTreeKeySelector</a></span> <span class="o">=</span> <span class="o">.</span><span class="n">any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L659-L717">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Removal"></a>
                <a name="//apple_ref/swift/Section/Removal" class="dashAnchor"></a>
                <a href="#/Removal">
                  <h3 class="section-name">Removal</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree11removeFirstFT_Txq__"></a>
                    <a name="//apple_ref/swift/Method/removeFirst()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree11removeFirstFT_Txq__">removeFirst()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove and return the first element.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">removeFirst</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Element</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L727-L729">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree10removeLastFT_Txq__"></a>
                    <a name="//apple_ref/swift/Method/removeLast()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree10removeLastFT_Txq__">removeLast()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove and return the last element.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">removeLast</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Element</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L735-L737">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree8popFirstFT_GSqTxq___"></a>
                    <a name="//apple_ref/swift/Method/popFirst()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree8popFirstFT_GSqTxq___">popFirst()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove and return the first element, or return <code>nil</code> if the tree is empty.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">popFirst</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L743-L746">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree7popLastFT_GSqTxq___"></a>
                    <a name="//apple_ref/swift/Method/popLast()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree7popLastFT_GSqTxq___">popLast()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove and return the first element, or return <code>nil</code> if the tree is empty.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">popLast</span><span class="p">()</span> <span class="o">-&gt;</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L752-L755">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree11removeFirstFSiT_"></a>
                    <a name="//apple_ref/swift/Method/removeFirst(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree11removeFirstFSiT_">removeFirst(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove the first <code>n</code> elements from this tree.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>) + <code>n</code>)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">removeFirst</span><span class="p">(</span><span class="n">_</span> <span class="nv">n</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L760-L769">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree10removeLastFSiT_"></a>
                    <a name="//apple_ref/swift/Method/removeLast(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree10removeLastFSiT_">removeLast(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove the last <code>n</code> elements from this tree.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>) + <code>n</code>)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">removeLast</span><span class="p">(</span><span class="n">_</span> <span class="nv">n</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L774-L783">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6removeFT8atOffsetSi_Txq__"></a>
                    <a name="//apple_ref/swift/Method/remove(atOffset:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6removeFT8atOffsetSi_Txq__">remove(atOffset:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove and return the element at the specified offset.</p>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    When you need to perform multiple modifications on the same tree,
<code><a href="../Classes/BTreeCursor.html">BTreeCursor</a></code> provides an alternative interface that&rsquo;s often more efficient.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">remove</span><span class="p">(</span><span class="n">atOffset</span> <span class="nv">offset</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Element</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L791-L836">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6removeFTx2atOS_16BTreeKeySelector_GSqTxq___"></a>
                    <a name="//apple_ref/swift/Method/remove(_:at:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6removeFTx2atOS_16BTreeKeySelector_GSqTxq___">remove(_:at:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove an element with the specified key, if it exists.
If there are multiple elements with the same key, <code>selector</code> indicates which matching element to remove.</p>

<div class="aside aside-returns">
    <p class="aside-title">Returns</p>
    The removed element, or <code>nil</code> if there was no element with <code>key</code> in the tree.

</div>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    When you need to perform multiple modifications on the same tree,
<code><a href="../Classes/BTreeCursor.html">BTreeCursor</a></code> provides an alternative interface that&rsquo;s often more efficient.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">remove</span><span class="p">(</span><span class="n">_</span> <span class="nv">key</span><span class="p">:</span> <span class="kt">Key</span><span class="p">,</span> <span class="n">at</span> <span class="nv">selector</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeKeySelector.html">BTreeKeySelector</a></span> <span class="o">=</span> <span class="o">.</span><span class="n">any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Element</span><span class="p">?</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>The removed element, or <code>nil</code> if there was no element with <code>key</code> in the tree.</p>

                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L846-L887">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6removeFT2atGVS_10BTreeIndexxq___Txq__"></a>
                    <a name="//apple_ref/swift/Method/remove(at:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6removeFT2atGVS_10BTreeIndexxq___Txq__">remove(at:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove and return the element referenced by the given index.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">remove</span><span class="p">(</span><span class="n">at</span> <span class="nv">index</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Element</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L893-L897">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree9removeAllFT_T_"></a>
                    <a name="//apple_ref/swift/Method/removeAll()" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree9removeAllFT_T_">removeAll()</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Remove all elements from this tree.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">removeAll</span><span class="p">()</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L900-L902">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Subtree%20extraction"></a>
                <a name="//apple_ref/swift/Section/Subtree extraction" class="dashAnchor"></a>
                <a href="#/Subtree%20extraction">
                  <h3 class="section-name">Subtree extraction</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6prefixFSiGS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/prefix(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6prefixFSiGS0_xq__">prefix(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subtree containing the initial <code>maxLength</code> elements in this tree.</p>

<p>If <code>maxLength</code> exceeds <code>self.count</code>, the result contains all the elements of <code>self</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prefix</span><span class="p">(</span><span class="n">_</span> <span class="nv">maxLength</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L913-L922">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree8dropLastFSiGS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/dropLast(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree8dropLastFSiGS0_xq__">dropLast(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subtree containing all but the last <code>n</code> elements.
If <code>n</code> exceeds the number of elements in the tree, the result is an empty tree.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">dropLast</span><span class="p">(</span><span class="n">_</span> <span class="nv">n</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L928-L931">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6prefixFT4upToGVS_10BTreeIndexxq___GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/prefix(upTo:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6prefixFT4upToGVS_10BTreeIndexxq___GS0_xq__">prefix(upTo:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subtree containing all elements before the specified index.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prefix</span><span class="p">(</span><span class="n">upTo</span> <span class="nv">end</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L936-L942">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6prefixFT4upTox_GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/prefix(upTo:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6prefixFT4upTox_GS0_xq__">prefix(upTo:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subtree containing all elements whose key is less than <code>key</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prefix</span><span class="p">(</span><span class="n">upTo</span> <span class="nv">end</span><span class="p">:</span> <span class="kt">Key</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L947-L953">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6prefixFT7throughGVS_10BTreeIndexxq___GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/prefix(through:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6prefixFT7throughGVS_10BTreeIndexxq___GS0_xq__">prefix(through:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subtree containing all elements at or before the specified index.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prefix</span><span class="p">(</span><span class="n">through</span> <span class="nv">stop</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L958-L960">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6prefixFT7throughx_GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/prefix(through:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6prefixFT7throughx_GS0_xq__">prefix(through:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subtree containing all elements whose key is less than or equal to <code>key</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">prefix</span><span class="p">(</span><span class="n">through</span> <span class="nv">stop</span><span class="p">:</span> <span class="kt">Key</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L965-L971">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6suffixFSiGS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/suffix(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6suffixFSiGS0_xq__">suffix(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a tree containing the final <code>maxLength</code> elements in this tree.</p>

<p>If <code>maxLength</code> exceeds <code>self.count</code>, the result contains all the elements of <code>self</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">suffix</span><span class="p">(</span><span class="n">_</span> <span class="nv">maxLength</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L978-L987">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree9dropFirstFSiGS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/dropFirst(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree9dropFirstFSiGS0_xq__">dropFirst(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subtree containing all but the first <code>n</code> elements.
If <code>n</code> exceeds the number of elements in the tree, the result is an empty tree.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">dropFirst</span><span class="p">(</span><span class="n">_</span> <span class="nv">n</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L993-L996">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6suffixFT4fromGVS_10BTreeIndexxq___GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/suffix(from:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6suffixFT4fromGVS_10BTreeIndexxq___GS0_xq__">suffix(from:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subtree containing all elements at or after the specified index.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">suffix</span><span class="p">(</span><span class="n">from</span> <span class="nv">start</span><span class="p">:</span> <span class="kt">Index</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L1001-L1009">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree6suffixFT4fromx_GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/suffix(from:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree6suffixFT4fromx_GS0_xq__">suffix(from:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns a subtree containing all elements whose key is greater than or equal to <code>key</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">suffix</span><span class="p">(</span><span class="n">from</span> <span class="nv">start</span><span class="p">:</span> <span class="kt">Key</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L1014-L1021">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree7subtreeFT4withGVs5RangeGVS_10BTreeIndexxq____GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/subtree(with:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree7subtreeFT4withGVs5RangeGVS_10BTreeIndexxq____GS0_xq__">subtree(with:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a subtree consisting of elements in the specified range of indexes.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">subtree</span><span class="p">(</span><span class="n">with</span> <span class="nv">range</span><span class="p">:</span> <span class="kt">Range</span><span class="o">&lt;</span><span class="kt">Index</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span><span class="o">&lt;</span><span class="kt">Key</span><span class="p">,</span> <span class="kt">Value</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L1026-L1039">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree7subtreeFT11withOffsetsGVs5RangeSi__GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/subtree(withOffsets:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree7subtreeFT11withOffsetsGVs5RangeSi__GS0_xq__">subtree(withOffsets:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a subtree consisting of elements in the specified range of offsets.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">subtree</span><span class="p">(</span><span class="n">withOffsets</span> <span class="nv">offsets</span><span class="p">:</span> <span class="kt">Range</span><span class="o">&lt;</span><span class="kt">Int</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span><span class="o">&lt;</span><span class="kt">Key</span><span class="p">,</span> <span class="kt">Value</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L1044-L1050">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree7subtreeFT4fromx2tox_GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/subtree(from:to:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree7subtreeFT4fromx2tox_GS0_xq__">subtree(from:to:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a subtree consisting of all elements with keys greater than or equal to <code>start</code> but less than <code>end</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">subtree</span><span class="p">(</span><span class="n">from</span> <span class="nv">start</span><span class="p">:</span> <span class="kt">Key</span><span class="p">,</span> <span class="n">to</span> <span class="nv">end</span><span class="p">:</span> <span class="kt">Key</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span><span class="o">&lt;</span><span class="kt">Key</span><span class="p">,</span> <span class="kt">Value</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L1055-L1058">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree7subtreeFT4fromx7throughx_GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/subtree(from:through:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree7subtreeFT4fromx7throughx_GS0_xq__">subtree(from:through:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a submap consisting of all elements with keys greater than or equal to <code>start</code> but less than or equal to <code>end</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">subtree</span><span class="p">(</span><span class="n">from</span> <span class="nv">start</span><span class="p">:</span> <span class="kt">Key</span><span class="p">,</span> <span class="n">through</span> <span class="nv">stop</span><span class="p">:</span> <span class="kt">Key</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span><span class="o">&lt;</span><span class="kt">Key</span><span class="p">,</span> <span class="kt">Value</span><span class="o">&gt;</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTree.swift#L1063-L1066">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Merging%20and%20set%20operations"></a>
                <a name="//apple_ref/swift/Section/Merging and set operations" class="dashAnchor"></a>
                <a href="#/Merging%20and%20set%20operations">
                  <h3 class="section-name">Merging and set operations</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree5unionFTGS0_xq__2byOS_21BTreeMatchingStrategy_GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/union(_:by:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree5unionFTGS0_xq__2byOS_21BTreeMatchingStrategy_GS0_xq__">union(_:by:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Merge elements from two trees into a new tree, and return it.</p>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    <p>Parameter other: Any tree with the same order as <code>self</code>.</p>

</div>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    <p>Parameter strategy:
 When <code>.groupingMatches</code>, elements in <code>self</code> whose keys also appear in <code>other</code> are not included in the result.
 If neither input tree had duplicate keys on its own, the result won&rsquo;t have any duplicates, either.</p>

<p>When <code>.countingMatches</code>, all elements in both trees are kept in the result, including ones with duplicate keys.
 The result may have duplicate keys, even if the input trees only had unique-keyed elements.</p>

</div>

<div class="aside aside-returns">
    <p class="aside-title">Returns</p>
    <p>A tree with elements from <code>self</code> with matching keys in <code>other</code> removed.</p>

</div>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    <p>The elements of the two input trees may interleave and overlap in any combination.
However, if there are long runs of non-interleaved elements, parts of the input trees will be entirely
skipped instead of elementwise processing. This may drastically improve performance.</p>

<p>When <code>strategy == .groupingMatches</code>, this function also detects shared subtrees between the two trees,
and links them directly into the result when possible. (Otherwise matching keys are individually processed.)</p>

</div>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <p><code>self.order == other.order</code></p>

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <p>Complexity:</p>

<ul>
<li>O(min(<code>self.count</code>, <code>other.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">union</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">,</span> <span class="n">by</span> <span class="nv">strategy</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeMatchingStrategy.html">BTreeMatchingStrategy</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>other</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Any tree with the same order as <code>self</code>.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>strategy</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>When <code>.groupingMatches</code>, elements in <code>self</code> whose keys also appear in <code>other</code> are not included in the result. If neither input tree had duplicate keys on its own, the result won’t have any duplicates, either.</p>
<p>When <code>.countingMatches</code>, all elements in both trees are kept in the result, including ones with duplicate keys. The result may have duplicate keys, even if the input trees only had unique-keyed elements.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>A tree with elements from <code>self</code> with matching keys in <code>other</code> removed.</p>

                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeMerger.swift#L57-L75">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree11subtractingFTGS0_xq__2byOS_21BTreeMatchingStrategy_GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/subtracting(_:by:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree11subtractingFTGS0_xq__2byOS_21BTreeMatchingStrategy_GS0_xq__">subtracting(_:by:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a tree with the same elements as <code>self</code> except those with matching keys in <code>other</code>.</p>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    <p>Parameter other: Any tree with the same order as <code>self</code>.</p>

</div>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    <p>Parameter strategy:
 When <code>.groupingMatches</code>, all elements in <code>self</code> that have a matching key in <code>other</code> are removed.</p>

<p>When <code>.countingMatches</code>, for each key in <code>self</code>, only as many matching elements are removed as the key&rsquo;s multiplicity in <code>other</code>.</p>

</div>

<div class="aside aside-returns">
    <p class="aside-title">Returns</p>
    <p>A tree with elements from <code>self</code> with matching keys in <code>other</code> removed.</p>

</div>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    <p>The elements of the two input trees may interleave and overlap in any combination.
However, if there are long runs of non-interleaved elements, parts of the input trees will be entirely
skipped or linked into the result instead of elementwise processing. This may drastically improve performance.</p>

<p>This function also detects and skips over shared subtrees between the two trees.
(Keys that appear in both trees otherwise require individual processing.)</p>

</div>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <p><code>self.order == other.order</code></p>

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <p>Complexity:</p>

<ul>
<li>O(min(<code>self.count</code>, <code>tree.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>tree.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">subtracting</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">,</span> <span class="n">by</span> <span class="nv">strategy</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeMatchingStrategy.html">BTreeMatchingStrategy</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>other</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Any tree with the same order as <code>self</code>.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>strategy</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>When <code>.groupingMatches</code>, all elements in <code>self</code> that have a matching key in <code>other</code> are removed.</p>
<p>When <code>.countingMatches</code>, for each key in <code>self</code>, only as many matching elements are removed as the key’s multiplicity in <code>other</code>.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>A tree with elements from <code>self</code> with matching keys in <code>other</code> removed.</p>

                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeMerger.swift#L101-L115">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree19symmetricDifferenceFTGS0_xq__2byOS_21BTreeMatchingStrategy_GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/symmetricDifference(_:by:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree19symmetricDifferenceFTGS0_xq__2byOS_21BTreeMatchingStrategy_GS0_xq__">symmetricDifference(_:by:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a tree combining the elements of <code>self</code> and <code>other</code> except those whose keys can be matched in both trees.</p>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    <p>Parameter other: Any tree with the same order as <code>self</code>.</p>

</div>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    <p>Parameter strategy:
 When <code>.groupingMatches</code>, all elements in both trees are removed whose key appears in both
 trees, regardless of their multiplicities.</p>

<p>When <code>.countingMatches</code>, for each key, only as many matching elements are removed as the minimum of the
   key&rsquo;s multiplicities in the two trees, leaving <q>extra</q> occurences from the <q>longer</q> tree in the result.</p>

</div>

<div class="aside aside-returns">
    <p class="aside-title">Returns</p>
    <p>A tree combining elements of <code>self</code> and <code>other</code> except those whose keys can be matched in both trees.</p>

</div>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    <p>The elements of the two input trees may interleave and overlap in any combination.
However, if there are long runs of non-interleaved elements, parts of the input trees will be entirely
linked into the result instead of elementwise processing. This may drastically improve performance.</p>

<p>This function also detects and skips over shared subtrees between the two trees.
(Keys that appear in both trees otherwise require individual processing.)</p>

</div>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <p><code>self.order == other.order</code></p>

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <p>Complexity:</p>

<ul>
<li>O(min(<code>self.count</code>, <code>other.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">symmetricDifference</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">,</span> <span class="n">by</span> <span class="nv">strategy</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeMatchingStrategy.html">BTreeMatchingStrategy</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>other</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Any tree with the same order as <code>self</code>.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>strategy</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>When <code>.groupingMatches</code>, all elements in both trees are removed whose key appears in both trees, regardless of their multiplicities.</p>
<p>When <code>.countingMatches</code>, for each key, only as many matching elements are removed as the minimum of the key’s multiplicities in the two trees, leaving “extra” occurences from the “longer” tree in the result.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>A tree combining elements of <code>self</code> and <code>other</code> except those whose keys can be matched in both trees.</p>

                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeMerger.swift#L144-L159">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree12intersectionFTGS0_xq__2byOS_21BTreeMatchingStrategy_GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/intersection(_:by:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree12intersectionFTGS0_xq__2byOS_21BTreeMatchingStrategy_GS0_xq__">intersection(_:by:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a tree with those elements of <code>other</code> whose keys are also included in <code>self</code>.</p>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    <p>Parameter other: Any tree with the same order as <code>self</code>.</p>

</div>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    <p>Parameter strategy:
 When <code>.groupingMatches</code>, all elements in <code>other</code> are included that have matching keys
 in <code>self</code>, regardless of multiplicities.</p>

<p>When <code>.countingMatches</code>, for each key, only as many matching elements from <code>other</code> are kept as 
 the minimum of the key&rsquo;s multiplicities in the two trees.</p>

</div>

<div class="aside aside-returns">
    <p class="aside-title">Returns</p>
    <p>A tree combining elements of <code>self</code> and <code>other</code> except those whose keys can be matched in both trees.</p>

</div>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    <p>The elements of the two input trees may interleave and overlap in any combination.
 However, if there are long runs of non-interleaved elements, parts of the input trees will be entirely
 skipped instead of elementwise processing. This may drastically improve performance.</p>

<p>This function also detects shared subtrees between the two trees,
 and links them directly into the result when possible.
 (Keys that appear in both trees otherwise require individual processing.)</p>

</div>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <p><code>self.order == other.order</code></p>

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <p>Complexity:</p>

<ul>
<li>O(min(<code>self.count</code>, <code>other.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>other.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">intersection</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">,</span> <span class="n">by</span> <span class="nv">strategy</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeMatchingStrategy.html">BTreeMatchingStrategy</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>other</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Any tree with the same order as <code>self</code>.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>strategy</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>When <code>.groupingMatches</code>, all elements in <code>other</code> are included that have matching keys in <code>self</code>, regardless of multiplicities.</p>
<p>When <code>.countingMatches</code>, for each key, only as many matching elements from <code>other</code> are kept as the minimum of the key’s multiplicities in the two trees.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>A tree combining elements of <code>self</code> and <code>other</code> except those whose keys can be matched in both trees.</p>

                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeMerger.swift#L188-L201">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree11subtractinguRd__s8SequencexzWd__8Iterator7Element_rFT10sortedKeysqd__2byOS_21BTreeMatchingStrategy_GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/subtracting(sortedKeys:by:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree11subtractinguRd__s8SequencexzWd__8Iterator7Element_rFT10sortedKeysqd__2byOS_21BTreeMatchingStrategy_GS0_xq__">subtracting(sortedKeys:by:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a tree that contains all elements in <code>self</code> whose key is not in the supplied sorted sequence.</p>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    <p>The keys of <code>self</code> may interleave and overlap with <code>sortedKeys</code> in any combination.
 However, if there are long runs of non-interleaved keys, parts of <code>self</code> will be entirely
 skipped instead of elementwise processing. This may drastically improve performance.</p>

</div>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <p><code>sortedKeys</code> is sorted in ascending order.</p>

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <p>O(<em>n</em> + <code>self.count</code>), where <em>n</em> is the number of keys in <code>sortedKeys</code>.</p>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="n">subtracting</span><span class="o">&lt;</span><span class="kt">S</span><span class="p">:</span> <span class="kt">Sequence</span><span class="o">&gt;</span><span class="p">(</span><span class="nv">sortedKeys</span><span class="p">:</span> <span class="kt">S</span><span class="p">,</span> <span class="n">by</span> <span class="nv">strategy</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeMatchingStrategy.html">BTreeMatchingStrategy</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span> <span class="k">where</span> <span class="kt">S</span><span class="o">.</span><span class="kt">Iterator</span><span class="o">.</span><span class="kt">Element</span> <span class="o">==</span> <span class="kt">Key</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeMerger.swift#L212-L243">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree12intersectionuRd__s8SequencexzWd__8Iterator7Element_rFT10sortedKeysqd__2byOS_21BTreeMatchingStrategy_GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/intersection(sortedKeys:by:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree12intersectionuRd__s8SequencexzWd__8Iterator7Element_rFT10sortedKeysqd__2byOS_21BTreeMatchingStrategy_GS0_xq__">intersection(sortedKeys:by:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return a tree that contains all elements in <code>self</code> whose key is in the supplied sorted sequence.</p>

<div class="aside aside-note">
    <p class="aside-title">Note</p>
    <p>The keys of <code>self</code> may interleave and overlap with <code>sortedKeys</code> in any combination.
 However, if there are long runs of non-interleaved keys, parts of <code>self</code> will be entirely
 skipped instead of elementwise processing. This may drastically improve performance.</p>

</div>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <p><code>sortedKeys</code> is sorted in ascending order.</p>

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <p>O(<em>n</em> + <code>self.count</code>), where <em>n</em> is the number of keys in <code>sortedKeys</code>.</p>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="n">intersection</span><span class="o">&lt;</span><span class="kt">S</span><span class="p">:</span> <span class="kt">Sequence</span><span class="o">&gt;</span><span class="p">(</span><span class="nv">sortedKeys</span><span class="p">:</span> <span class="kt">S</span><span class="p">,</span> <span class="n">by</span> <span class="nv">strategy</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeMatchingStrategy.html">BTreeMatchingStrategy</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">BTree</span> <span class="k">where</span> <span class="kt">S</span><span class="o">.</span><span class="kt">Iterator</span><span class="o">.</span><span class="kt">Element</span> <span class="o">==</span> <span class="kt">Key</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeMerger.swift#L254-L282">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Cursors"></a>
                <a name="//apple_ref/swift/Section/Cursors" class="dashAnchor"></a>
                <a href="#/Cursors">
                  <h3 class="section-name">Cursors</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree10withCursorurFzT8atOffsetSi4bodyFzGCS_11BTreeCursorxq__qd___qd__"></a>
                    <a name="//apple_ref/swift/Method/withCursor(atOffset:body:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree10withCursorurFzT8atOffsetSi4bodyFzGCS_11BTreeCursorxq__qd___qd__">withCursor(atOffset:body:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Call <code>body</code> with a cursor at <code>offset</code> in this tree.</p>

<div class="aside aside-warning">
    <p class="aside-title">Warning</p>
    Do not rely on anything about <code>self</code> (the <code>BTree</code> that is the target of this method) during the
execution of body: it will not appear to have the correct value.
Instead, use only the supplied cursor to manipulate the tree.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="n">withCursor</span><span class="o">&lt;</span><span class="kt">R</span><span class="o">&gt;</span><span class="p">(</span><span class="n">atOffset</span> <span class="nv">offset</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span> <span class="nv">body</span><span class="p">:</span> <span class="p">(</span><span class="kt">Cursor</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">R</span><span class="p">)</span> <span class="k">rethrows</span> <span class="o">-&gt;</span> <span class="kt">R</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeCursor.swift#L20-L27">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree17withCursorAtStarturFzFzGCS_11BTreeCursorxq__qd__qd__"></a>
                    <a name="//apple_ref/swift/Method/withCursorAtStart(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree17withCursorAtStarturFzFzGCS_11BTreeCursorxq__qd__qd__">withCursorAtStart(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Call <code>body</code> with a cursor at the start of this tree.</p>

<div class="aside aside-warning">
    <p class="aside-title">Warning</p>
    Do not rely on anything about <code>self</code> (the <code>BTree</code> that is the target of this method) during the
execution of body: it will not appear to have the correct value.
Instead, use only the supplied cursor to manipulate the tree.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="n">withCursorAtStart</span><span class="o">&lt;</span><span class="kt">R</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span> <span class="nv">body</span><span class="p">:</span> <span class="p">(</span><span class="kt">Cursor</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">R</span><span class="p">)</span> <span class="k">rethrows</span> <span class="o">-&gt;</span> <span class="kt">R</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeCursor.swift#L35-L37">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree15withCursorAtEndurFzFzGCS_11BTreeCursorxq__qd__qd__"></a>
                    <a name="//apple_ref/swift/Method/withCursorAtEnd(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree15withCursorAtEndurFzFzGCS_11BTreeCursorxq__qd__qd__">withCursorAtEnd(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Call <code>body</code> with a cursor at the end of this tree.</p>

<div class="aside aside-warning">
    <p class="aside-title">Warning</p>
    Do not rely on anything about <code>self</code> (the <code>BTree</code> that is the target of this method) during the
execution of body: it will not appear to have the correct value.
Instead, use only the supplied cursor to manipulate the tree.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="n">withCursorAtEnd</span><span class="o">&lt;</span><span class="kt">R</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span> <span class="nv">body</span><span class="p">:</span> <span class="p">(</span><span class="kt">Cursor</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">R</span><span class="p">)</span> <span class="k">rethrows</span> <span class="o">-&gt;</span> <span class="kt">R</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeCursor.swift#L45-L51">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree10withCursorurFzT5onKeyx8choosingOS_16BTreeKeySelector4bodyFzGCS_11BTreeCursorxq__qd___qd__"></a>
                    <a name="//apple_ref/swift/Method/withCursor(onKey:choosing:body:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree10withCursorurFzT5onKeyx8choosingOS_16BTreeKeySelector4bodyFzGCS_11BTreeCursorxq__qd___qd__">withCursor(onKey:choosing:body:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Call <code>body</code> with a cursor positioned on <code>key</code> in this tree.
If there are multiple elements with the same key, <code>selector</code> indicates which matching element to find.</p>

<div class="aside aside-warning">
    <p class="aside-title">Warning</p>
    Do not rely on anything about <code>self</code> (the <code>BTree</code> that is the target of this method) during the
execution of body: it will not appear to have the correct value.
Instead, use only the supplied cursor to manipulate the tree.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="n">withCursor</span><span class="o">&lt;</span><span class="kt">R</span><span class="o">&gt;</span><span class="p">(</span><span class="n">onKey</span> <span class="nv">key</span><span class="p">:</span> <span class="kt">Key</span><span class="p">,</span> <span class="n">choosing</span> <span class="nv">selector</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeKeySelector.html">BTreeKeySelector</a></span> <span class="o">=</span> <span class="o">.</span><span class="n">any</span><span class="p">,</span> <span class="nv">body</span><span class="p">:</span> <span class="p">(</span><span class="kt">Cursor</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">R</span><span class="p">)</span> <span class="k">rethrows</span> <span class="o">-&gt;</span> <span class="kt">R</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeCursor.swift#L60-L66">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree10withCursorurFzT2atGVS_10BTreeIndexxq__4bodyFzGCS_11BTreeCursorxq__qd___qd__"></a>
                    <a name="//apple_ref/swift/Method/withCursor(at:body:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree10withCursorurFzT2atGVS_10BTreeIndexxq__4bodyFzGCS_11BTreeCursorxq__qd___qd__">withCursor(at:body:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Call <code>body</code> with a cursor positioned on <code>index</code> in this tree.</p>

<div class="aside aside-warning">
    <p class="aside-title">Warning</p>
    Do not rely on anything about <code>self</code> (the <code>BTree</code> that is the target of this method) during the
execution of body: it will not appear to have the correct value.
Instead, use only the supplied cursor to manipulate the tree.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="n">withCursor</span><span class="o">&lt;</span><span class="kt">R</span><span class="o">&gt;</span><span class="p">(</span><span class="n">at</span> <span class="nv">index</span><span class="p">:</span> <span class="kt">Index</span><span class="p">,</span> <span class="nv">body</span><span class="p">:</span> <span class="p">(</span><span class="kt">Cursor</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">R</span><span class="p">)</span> <span class="k">rethrows</span> <span class="o">-&gt;</span> <span class="kt">R</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeCursor.swift#L74-L81">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Comparison"></a>
                <a name="//apple_ref/swift/Section/Comparison" class="dashAnchor"></a>
                <a href="#/Comparison">
                  <h3 class="section-name">Comparison</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree13elementsEqualFzTGS0_xq__2byFzTTxq__Txq___Sb_Sb"></a>
                    <a name="//apple_ref/swift/Method/elementsEqual(_:by:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree13elementsEqualFzTGS0_xq__2byFzTTxq__Txq___Sb_Sb">elementsEqual(_:by:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return <code>true</code> iff <code>self</code> and <code>other</code> contain equivalent elements, using <code>isEquivalent</code> as the equivalence test.</p>

<p>This method skips over shared subtrees when possible; this can drastically improve performance when the 
two trees are divergent mutations originating from the same value.</p>

<div class="aside aside-requires">
    <p class="aside-title">Requires</p>
    <code>isEquivalent</code> is an <a href="https://en.wikipedia.org/wiki/Equivalence_relation">equivalence relation</a>.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">elementsEqual</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">,</span> <span class="n">by</span> <span class="nv">isEquivalent</span><span class="p">:</span> <span class="p">(</span><span class="kt">Element</span><span class="p">,</span> <span class="kt">Element</span><span class="p">)</span> <span class="k">throws</span> <span class="o">-&gt;</span> <span class="kt">Bool</span><span class="p">)</span> <span class="k">rethrows</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeComparisons.swift#L21-L45">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:Fe5BTree0_Rxs10Comparable_s9EquatablerVS_5BTree13elementsEqualFGS2_xq__Sb"></a>
                    <a name="//apple_ref/swift/Method/elementsEqual(_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:Fe5BTree0_Rxs10Comparable_s9EquatablerVS_5BTree13elementsEqualFGS2_xq__Sb">elementsEqual(_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return <code>true</code> iff <code>self</code> and <code>other</code> contain equal elements.</p>

<p>This method skips over shared subtrees when possible; this can drastically improve performance when the
two trees are divergent mutations originating from the same value.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">elementsEqual</span><span class="p">(</span><span class="n">_</span> <span class="nv">other</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeComparisons.swift#L55-L57">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:ZFe5BTree0_Rxs10Comparable_s9EquatablerVS_5BTreeoi2eeFTGS2_xq__GS2_xq___Sb"></a>
                    <a name="//apple_ref/swift/Method/==(_:_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:ZFe5BTree0_Rxs10Comparable_s9EquatablerVS_5BTreeoi2eeFTGS2_xq__GS2_xq___Sb">==(_:_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return <code>true</code> iff <code>a</code> and <code>b</code> contain equal elements.</p>

<p>This method skips over shared subtrees when possible; this can drastically improve performance when the
two trees are divergent mutations originating from the same value.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="o">==</span> <span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeComparisons.swift#L65-L67">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:ZFe5BTree0_Rxs10Comparable_s9EquatablerVS_5BTreeoi2neFTGS2_xq__GS2_xq___Sb"></a>
                    <a name="//apple_ref/swift/Method/!=(_:_:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:ZFe5BTree0_Rxs10Comparable_s9EquatablerVS_5BTreeoi2neFTGS2_xq__GS2_xq___Sb">!=(_:_:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Return <code>true</code> iff <code>a</code> and <code>b</code> do not contain equal elements.</p>

<p>This method skips over shared subtrees when possible; this can drastically improve performance when the
two trees are divergent mutations originating from the same value.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>)

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">static</span> <span class="kd">func</span> <span class="o">!=</span> <span class="p">(</span><span class="nv">a</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">,</span> <span class="nv">b</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeComparisons.swift#L75-L77">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree10isDisjointFT4withGS0_xq___Sb"></a>
                    <a name="//apple_ref/swift/Method/isDisjoint(with:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree10isDisjointFT4withGS0_xq___Sb">isDisjoint(with:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns true iff this tree has no elements whose keys are also in <code>tree</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>tree.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>tree.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">isDisjoint</span><span class="p">(</span><span class="n">with</span> <span class="nv">tree</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeComparisons.swift#L86-L105">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree8isSubsetFT2ofGS0_xq__2byOS_21BTreeMatchingStrategy_Sb"></a>
                    <a name="//apple_ref/swift/Method/isSubset(of:by:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree8isSubsetFT2ofGS0_xq__2byOS_21BTreeMatchingStrategy_Sb">isSubset(of:by:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns true iff all keys in <code>self</code> are also in <code>tree</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>tree.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>tree.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">isSubset</span><span class="p">(</span><span class="n">of</span> <span class="nv">tree</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">,</span> <span class="n">by</span> <span class="nv">strategy</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeMatchingStrategy.html">BTreeMatchingStrategy</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeComparisons.swift#L112-L114">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree14isStrictSubsetFT2ofGS0_xq__2byOS_21BTreeMatchingStrategy_Sb"></a>
                    <a name="//apple_ref/swift/Method/isStrictSubset(of:by:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree14isStrictSubsetFT2ofGS0_xq__2byOS_21BTreeMatchingStrategy_Sb">isStrictSubset(of:by:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns true iff all keys in <code>self</code> are also in <code>tree</code>,
but <code>tree</code> contains at least one key that isn&rsquo;t in <code>self</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>tree.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>tree.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">isStrictSubset</span><span class="p">(</span><span class="n">of</span> <span class="nv">tree</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">,</span> <span class="n">by</span> <span class="nv">strategy</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeMatchingStrategy.html">BTreeMatchingStrategy</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeComparisons.swift#L122-L124">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree10isSupersetFT2ofGS0_xq__2byOS_21BTreeMatchingStrategy_Sb"></a>
                    <a name="//apple_ref/swift/Method/isSuperset(of:by:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree10isSupersetFT2ofGS0_xq__2byOS_21BTreeMatchingStrategy_Sb">isSuperset(of:by:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns true iff all keys in <code>tree</code> are also in <code>self</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>tree.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>tree.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">isSuperset</span><span class="p">(</span><span class="n">of</span> <span class="nv">tree</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">,</span> <span class="n">by</span> <span class="nv">strategy</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeMatchingStrategy.html">BTreeMatchingStrategy</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeComparisons.swift#L131-L133">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTree16isStrictSupersetFT2ofGS0_xq__2byOS_21BTreeMatchingStrategy_Sb"></a>
                    <a name="//apple_ref/swift/Method/isStrictSuperset(of:by:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTree16isStrictSupersetFT2ofGS0_xq__2byOS_21BTreeMatchingStrategy_Sb">isStrictSuperset(of:by:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Returns true iff all keys in <code>tree</code> are also in <code>self</code>,
but <code>self</code> contains at least one key that isn&rsquo;t in <code>tree</code>.</p>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    <ul>
<li>O(min(<code>self.count</code>, <code>tree.count</code>)) in general.</li>
<li>O(log(<code>self.count</code> + <code>tree.count</code>)) if there are only a constant amount of interleaving element runs.</li>
</ul>

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">isStrictSuperset</span><span class="p">(</span><span class="n">of</span> <span class="nv">tree</span><span class="p">:</span> <span class="kt">BTree</span><span class="p">,</span> <span class="n">by</span> <span class="nv">strategy</span><span class="p">:</span> <span class="kt"><a href="../Enums/BTreeMatchingStrategy.html">BTreeMatchingStrategy</a></span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Bool</span></code></pre>

                        </div>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeComparisons.swift#L141-L143">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
            <div class="task-group">
              <div class="task-name-container">
                <a name="/Bulk%20loading%20initializers"></a>
                <a name="//apple_ref/swift/Section/Bulk loading initializers" class="dashAnchor"></a>
                <a href="#/Bulk%20loading%20initializers">
                  <h3 class="section-name">Bulk loading initializers</h3>
                </a>
              </div>
              <ul class="item-container">
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTreecuRd__s8SequenceWd__8Iterator7Element_zTxq__rFTqd__14dropDuplicatesSb5orderSi_GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/init(_:dropDuplicates:order:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTreecuRd__s8SequenceWd__8Iterator7Element_zTxq__rFTqd__14dropDuplicatesSb5orderSi_GS0_xq__">init(_:dropDuplicates:order:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Create a new B-tree from elements of an unsorted sequence, using a stable sort algorithm.</p>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    Parameter elements: An unsorted sequence of arbitrary length.

</div>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    Parameter order: The desired B-tree order. If not specified (recommended), the default order is used.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(count * log(<code><a href="../Structs/BTree.html#/s:vV5BTree5BTree5countSi">count</a></code>))

</div>

<div class="aside aside-see-also">
    <p class="aside-title">See also</p>
    <code>init(sortedElements:order:fillFactor:)</code> for a (faster) variant that can be used if the sequence is already sorted.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">init</span><span class="o">&lt;</span><span class="kt">S</span><span class="p">:</span> <span class="kt">Sequence</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span> <span class="nv">elements</span><span class="p">:</span> <span class="kt">S</span><span class="p">,</span> <span class="nv">dropDuplicates</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nv">order</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="kt">Node</span><span class="o">.</span><span class="n">defaultOrder</span><span class="p">)</span>
        <span class="k">where</span> <span class="kt">S</span><span class="o">.</span><span class="kt">Iterator</span><span class="o">.</span><span class="kt">Element</span> <span class="o">==</span> <span class="kt">Element</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>elements</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>An unsorted sequence of arbitrary length.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>order</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The desired B-tree order. If not specified (recommended), the default order is used.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeBuilder.swift#L19-L39">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:FV5BTree5BTreecuRd__s8SequenceWd__8Iterator7Element_zTxq__rFT14sortedElementsqd__14dropDuplicatesSb5orderSi10fillFactorSd_GS0_xq__"></a>
                    <a name="//apple_ref/swift/Method/init(sortedElements:dropDuplicates:order:fillFactor:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:FV5BTree5BTreecuRd__s8SequenceWd__8Iterator7Element_zTxq__rFT14sortedElementsqd__14dropDuplicatesSb5orderSi10fillFactorSd_GS0_xq__">init(sortedElements:dropDuplicates:order:fillFactor:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Create a new B-tree from elements of a sequence sorted by key.</p>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    Parameter sortedElements: A sequence of arbitrary length, sorted by key.

</div>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    Parameter order: The desired B-tree order. If not specified (recommended), the default order is used.

</div>

<div class="aside aside-parameter">
    <p class="aside-title">Parameter</p>
    Parameter fillFactor: The desired fill factor in each node of the new tree. Must be between 0.5 and 1.0.
 If not specified, a value of 1.0 is used, i.e., nodes will be loaded with as many elements as possible.

</div>

<div class="aside aside-complexity">
    <p class="aside-title">Complexity</p>
    O(count)

</div>

<div class="aside aside-see-also">
    <p class="aside-title">See also</p>
    <code>init(elements:order:fillFactor:)</code> for a (slower) unsorted variant.

</div>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight"><code><span class="kd">public</span> <span class="kd">init</span><span class="o">&lt;</span><span class="kt">S</span><span class="p">:</span> <span class="kt">Sequence</span><span class="o">&gt;</span><span class="p">(</span><span class="n">sortedElements</span> <span class="nv">elements</span><span class="p">:</span> <span class="kt">S</span><span class="p">,</span> <span class="nv">dropDuplicates</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">false</span><span class="p">,</span> <span class="nv">order</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="kt">Node</span><span class="o">.</span><span class="n">defaultOrder</span><span class="p">,</span> <span class="nv">fillFactor</span><span class="p">:</span> <span class="kt">Double</span> <span class="o">=</span> <span class="mi">1</span><span class="p">)</span> <span class="k">where</span> <span class="kt">S</span><span class="o">.</span><span class="kt">Iterator</span><span class="o">.</span><span class="kt">Element</span> <span class="o">==</span> <span class="kt">Element</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>sortedElements</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>A sequence of arbitrary length, sorted by key.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>order</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The desired B-tree order. If not specified (recommended), the default order is used.</p>

                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>fillFactor</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The desired fill factor in each node of the new tree. Must be between 0.5 and 1.0. If not specified, a value of 1.0 is used, i.e., nodes will be loaded with as many elements as possible.</p>

                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/lorentey/BTree/tree/v4.0.1/Sources/BTreeBuilder.swift#L49-L52">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
          </div>
        </section>

      </article>
    </div>
    <section class="footer">
      <p>&copy; 2016 <a class="link" href="https://twitter.com/lorentey" target="_blank" rel="external">Károly Lőrentey</a>. All rights reserved. (Last updated: 2016-11-08)</p>
      <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
    </section>
  </body>
</div>
</html>
